package customer.GUI.components.wizard.initwizard;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import customer.NetPlayGGXCustomer;
import customer.GUI.components.wizard.NetPlayCustomWizardPanelDesc;
import customer.core.InitManager;

public class NetPlayCustomInitPanelDesc2 extends NetPlayCustomWizardPanelDesc implements ActionListener{
	public static final String IDENTIFIER = "EMUL_PANEL";
    
	private NetPlayCustomInitPanel2 pan2 ;
	
    public NetPlayCustomInitPanelDesc2() {
    	pan2 = new NetPlayCustomInitPanel2();
    	pan2.addBrowseButtonsListener(this);
    	
    	setPanelDescriptorIdentifier(NetPlayCustomInitPanelDesc2.IDENTIFIER);
    	setPanelComponent(pan2);
    }
    
    public Object getNextPanelDescriptor() {
        return NetPlayCustomInitPanelDescFinal.IDENTIFIER;
    }
    
    public Object getBackPanelDescriptor() {
        return NetPlayCustomInitPanelDesc1.IDENTIFIER;
    }  
    
    public void aboutToDisplayPanel() {
        setNextButtonAccordingToCheckBox(null);
    }    
    
    public void actionPerformed(ActionEvent e) {
        setNextButtonAccordingToCheckBox(e);
    }
            
    
    private void setNextButtonAccordingToCheckBox(ActionEvent e) {
        if(e != null && e.getActionCommand().equals("emul"))
 		{
 			pan2.getChooserEmulFolder().showOpenDialog(NetPlayGGXCustomer.getMainFrame());
 			pan2.setEmulDirectory(pan2.getChooserEmulFolder().getSelectedFile());
 			pan2.getJtfEmulFolder().setText(pan2.getEmulDirectory().getAbsolutePath());
 			InitManager.setEmulFolder(pan2.getEmulDirectory());
 			pan2.setEmulSelected(true);
 		}
 		else if(e != null && e.getActionCommand().equals("roms"))
 		{
 			pan2.getChooserRomsFolder().showOpenDialog(NetPlayGGXCustomer.getMainFrame());
 			pan2.setRomsDirectory(pan2.getChooserRomsFolder().getSelectedFile());
 			pan2.getJtfRomsFolder().setText(pan2.getRomsDirectory().getAbsolutePath());
 			InitManager.setRomsFolder(pan2.getRomsDirectory());
 			pan2.setRomsSelected(true);
 		}
 		
 		if(pan2.isEmulSelected() && pan2.isRomsSelected())
 			getWizard().setNextFinishButtonEnabled(true);
 		else
 			getWizard().setNextFinishButtonEnabled(false);      
    
    }
}
